package com.example.dao;

import com.example.model.Goods;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.*;
@RunWith(Parameterized.class)
public class GoodsDaoTest3 {
    int input;
    int expected;
    public GoodsDaoTest3(int input,int expected){
        this.input=input;
        this.expected=expected;
    }

    @Parameterized.Parameters
    public static Collection<?> data(){
        return Arrays.asList(new Object[][]{
                {0,148},{1,10}
        });
    }
    @Test
    public void getCountOfGoodsByTypeID1() throws SQLException{
        Assertions.assertEquals(expected,
                new GoodsDao().getCountOfGoodsByTypeID(input));
    }


    @Test
    public void testGetGoodsById() throws SQLException {

        String excepted="意大利芝士饼干";
        String actual=new GoodsDao().getGoodsById(21).getName();
        Assertions.assertEquals(excepted,actual);
    }
    @Test
    public void getCountOfGoodsByTypeID() throws SQLException {
        int expected=148;
        int actual=new GoodsDao().getCountOfGoodsByTypeID(0);
        Assertions.assertEquals(expected,actual);

    }
    @Test
    public void getCountOfGoodsByTypeID2() throws SQLException {
        int expected2=10;
        int actual2=new GoodsDao().getCountOfGoodsByTypeID(1);
        Assertions.assertEquals(expected2,actual2);
    }
    @Test
    public void getCountOfGoodsByTypeID3() throws SQLException {
        int expected=200;
        int actual=new GoodsDao().getCountOfGoodsByTypeID(0);
        Assertions.assertEquals(expected,actual);
    }
}